package com.example.file;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.net.InetAddress;

@SpringBootApplication
public class FileApplication {


    public static String port;

    public static void main(String[] args) {
        SpringApplication.run(FileApplication.class, args);
        // 在 Spring Boot 启动后打开浏览器

            try {
                InetAddress inetAddress = InetAddress.getLocalHost();
                // 获取本地机器的 IP 地址
                String ipAddress = inetAddress.getHostAddress();

                // 或者使用ProcessBuilder类
                ProcessBuilder processBuilder = new ProcessBuilder("cmd", "/c", "start", "http://"+ipAddress+":"+port+"/#/inner");
                processBuilder.start();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }

    }

    @Value("${server.port}")
    public  void setPort(String port) {
        FileApplication.port = port;
    }
}
